Skip to content

Conversation

@ThomsonTan
Copy link
Contributor

CMAKE_SOURCE_DIR is used to download nlohmann_json from github when it is not installed. But it is expected to be CMAKE_CURRENT_SOURCE_DIR which is different than CMAKE_SOURCE_DIR when building as an external component of opentelemetry-cpp. This PR simplifies this by raising error if nlohmann is not installed before building.

@ThomsonTan ThomsonTan requested review from Copilot and lalitb July 23, 2025 17:45
@ThomsonTan ThomsonTan requested a review from a team as a code owner July 23, 2025 17:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a build issue in the Fluentd exporter when opentelemetry-cpp is built as an external component. The change prevents incorrect path resolution for the nlohmann_json dependency by requiring it to be pre-installed rather than attempting to download it.

  • Adds conditional logic to check if building as main project before attempting to clone nlohmann_json
  • Replaces automatic dependency download with a fatal error when nlohmann_json is missing in external builds

include_directories(${nlohmann_json_SOURCE_DIR})
message("nlohmann_json package was not found. Cloning from github")
else()
message(FATAL_ERROR "nlohmann_json package was not found which is required for opentelemetry-cpp-fluentd. Please install it")
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message could be more helpful by providing installation guidance. Consider adding information about how to install nlohmann_json (e.g., package manager commands or minimum version requirements).

Suggested change
message(FATAL_ERROR "nlohmann_json package was not found which is required for opentelemetry-cpp-fluentd. Please install it")
message(FATAL_ERROR "nlohmann_json package was not found, which is required for opentelemetry-cpp-fluentd. Please install it using a package manager. For example:\n"
" - vcpkg: ./vcpkg install nlohmann-json\n"
" - apt (Ubuntu): sudo apt install nlohmann-json-dev\n"
" - Homebrew (macOS): brew install nlohmann-json\n"
"Ensure the package is available and meets the minimum version requirements.")

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the dependence installation instructions are not needed here.

@ThomsonTan ThomsonTan merged commit 5688d2e into open-telemetry:main Jul 23, 2025
2 checks passed
@ThomsonTan ThomsonTan deleted the fix_fluentd_dep_nlohmann branch July 23, 2025 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants